package org.xiangfei.server.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import org.xiangfei.codec.XFMessageDecoder;
import org.xiangfei.codec.XFMessageEncoder;


/** 
* @author feesx@qq.com
* @version 2017年7月6日 下午9:53:49 
*  
*/
public class XFServerInitializer extends ChannelInitializer<SocketChannel>{
    @Override
    public void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
//        pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));  
//        pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));  
        pipeline.addLast("decoder", new XFMessageDecoder());  
        pipeline.addLast("encoder", new XFMessageEncoder());  
        pipeline.addLast("handler", new XFServerHandler());
        System.out.println("SimpleChatClient:" + ch.remoteAddress() + "连接上");
    }
}
 
